package com.product.business.service.impl;

import java.util.List;

import com.product.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.product.business.mapper.PurchaseInfoMapper;
import com.product.business.domain.PurchaseInfo;
import com.product.business.service.IPurchaseInfoService;

/**
 * 采购企业信息Service业务层处理
 *
 * @author wanghui
 * @date 2022-08-20
 */
@Service
public class PurchaseInfoServiceImpl implements IPurchaseInfoService {
    @Autowired
    private PurchaseInfoMapper purchaseInfoMapper;

    /**
     * 查询采购企业信息
     *
     * @param companyId 采购企业信息主键
     * @return 采购企业信息
     */
    @Override
    public PurchaseInfo selectPurchaseInfoByCompanyId(Long companyId) {
        return purchaseInfoMapper.selectPurchaseInfoByCompanyId(companyId);
    }

    /**
     * 查询采购企业信息列表
     *
     * @param purchaseInfo 采购企业信息
     * @return 采购企业信息
     */
    @Override
    public List<PurchaseInfo> selectPurchaseInfoList(PurchaseInfo purchaseInfo) {
        return purchaseInfoMapper.selectPurchaseInfoList(purchaseInfo);
    }

    /**
     * 新增采购企业信息
     *
     * @param purchaseInfo 采购企业信息
     * @return 结果
     */
    @Override
    public int insertPurchaseInfo(PurchaseInfo purchaseInfo) {
        purchaseInfo.setCreateTime(DateUtils.getNowDate());
        return purchaseInfoMapper.insertPurchaseInfo(purchaseInfo);
    }

    /**
     * 修改采购企业信息
     *
     * @param purchaseInfo 采购企业信息
     * @return 结果
     */
    @Override
    public int updatePurchaseInfo(PurchaseInfo purchaseInfo) {
        purchaseInfo.setUpdateTime(DateUtils.getNowDate());
        return purchaseInfoMapper.updatePurchaseInfo(purchaseInfo);
    }

    /**
     * 批量删除采购企业信息
     *
     * @param companyIds 需要删除的采购企业信息主键
     * @return 结果
     */
    @Override
    public int deletePurchaseInfoByCompanyIds(Long[] companyIds) {
        return purchaseInfoMapper.deletePurchaseInfoByCompanyIds(companyIds);
    }

    /**
     * 删除采购企业信息信息
     *
     * @param companyId 采购企业信息主键
     * @return 结果
     */
    @Override
    public int deletePurchaseInfoByCompanyId(Long companyId) {
        return purchaseInfoMapper.deletePurchaseInfoByCompanyId(companyId);
    }
}
